package com.example.io.fileinputstream;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;

/**
 * @Author 尚智江
 * @description
 * @CreateDate 2024/1/9 22:11
 */
public class ByteStreamByIn5 {
    public static void main(String[] args) {
        FileInputStream fis = null;
        FileOutputStream fos = null;
        try{
            fis = new FileInputStream("C:\\Users\\28593\\Desktop\\上合文件\\Java面试就业冲刺宝典.pdf");
            fos = new FileOutputStream("E:\\SpringBoot\\Spring-Boot\\java-io\\src\\main\\resources\\a.pdf");
            // 拷贝
            int len;
            byte[] bytes = new byte[1024 * 1024 * 5];
            while ((len = fis.read(bytes)) != -1){
                fos.write(bytes,0,len);
            }
        }catch (IOException e){
            e.printStackTrace();
        }finally {
            try{
                if (fos != null){
                    fos.close();
                }
                if (fis != null){
                    fis.close();
                }
            }catch (IOException e){
                e.printStackTrace();
            }
        }
    }
}
